package com.exp.bookhouse.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.exp.bookhouse.util.AmountUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Date;

@ApiModel("订单实体类OrderDetail")
@TableName("tb_order_detail")
public class OrderDetail implements Serializable {

    @ApiModelProperty(value = "订单细节id")
    @TableId(type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "订单id")
    private Long orderId;       //订单id

    @ApiModelProperty(value = "书籍id")
    private Long bookId;        //书本id

    @ApiModelProperty(value = "书名")
    private String bookName;    //书名

    @ApiModelProperty(value = "书籍单价")
    private Long bookPrice;     //书本单价

    @TableField(exist = false)
    private String bookPriceStr;

    @ApiModelProperty(value = "书籍数量")
    private Integer bookNum;    //书本的数量

    @TableField(exist = false)
    private Integer bookQuantity;   //书本的数量

    @ApiModelProperty(value = "书籍小图")
    private String bookIcon;    //书本小图

    @ApiModelProperty(value = "创建时间",hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;    //创建时间

    @ApiModelProperty(value = "更新时间",hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;    //更新时间

    public OrderDetail() {
    }

    public String getBookPriceStr() {
        return bookPriceStr;
    }

    public void setBookPriceStr(String bookPriceStr) {
        this.bookPriceStr = bookPriceStr;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getBookId() {
        return bookId;
    }

    public void setBookId(Long bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public Long getBookPrice() {
        return bookPrice;
    }

    public void setBookPrice(Long bookPrice) {
        String str = "";
        if(bookPrice != null){
            str = AmountUtil.changeF2Y(bookPrice);
        }
        this.bookPriceStr = str;
        this.bookPrice = bookPrice;
    }

    public Integer getBookNum() {
        return bookNum;
    }

    public void setBookNum(Integer bookNum) {
        if(bookNum != null){
            this.bookQuantity = bookNum;
        }
        this.bookNum = bookNum;
    }

    public Integer getBookQuantity() {
        return bookQuantity;
    }

    public void setBookQuantity(Integer bookQuantity) {
        if(bookQuantity != null){
            this.bookNum = bookQuantity;
        }
        this.bookQuantity = bookQuantity;
    }

    public String getBookIcon() {
        return bookIcon;
    }

    public void setBookIcon(String bookIcon) {
        this.bookIcon = bookIcon;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "OrderDetail{" +
                "id=" + id +
                ", orderId=" + orderId +
                ", bookId=" + bookId +
                ", bookName='" + bookName + '\'' +
                ", bookPrice=" + bookPrice +
                ", bookNum=" + bookNum +
                ", bookQuantity=" + bookQuantity +
                ", bookIcon='" + bookIcon + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
